<template>
  <s-layout class="newsDetail" :title="state.info.title" :bgStyle="{ color: '#FFF' }">
 
    <view class='title'>{{state.info.title}}</view>
			<view class='list flex between'>
				<view class='label'>{{state.info.author}}</view>
				<view class='item'>{{state.info.createTime}}</view>
				<view class='item'><text class='iconfont icon-liulan'></text>{{state.info.visit}}</view>
			</view>
			<view class='conters'>
				<mp-html class="richtext" :content="state.content"></mp-html>
			</view>
			<view class="picTxt acea-row row-between-wrapper" v-if="storeInfo.id">
				<view class="pictrue">
					<image :src="storeInfo.image"></image>
				</view>
				<view class="text">
					<view class="name line1">{{storeInfo.storeName}}</view>
					<view class="money font-color">
						￥<text class="num">{{storeInfo.price}}</text>
					</view>
					<view class="y_money">￥{{storeInfo.otPrice}}</view>
				</view>
				<navigator :url="'/pages/goods/index?id='+storeInfo.id" hover-class="none" class="label"><text class="span">查看商品</text></navigator>
			</view>
  </s-layout>
</template>

<script setup>
  import { onLoad } from '@dcloudio/uni-app';
  import { reactive } from 'vue';
  import mall from '@/mall';

	import {
	getArticleDetails
	} from '@/mall/api/home.js';
  	import {
	getProductDetail
	} from '@/mall/api/goods.js';
  
  const state = reactive({
    title: '',
    content: '',
    info:{}
  });
  const productId = ref()
  const storeInfo = ref({})
  async function getRichTextContent(id) {
    const {data } = await getArticleDetails({id});
    state.info = data
     state.content = data.content;
    productId.value = data.productId
    uni.setNavigationBarTitle({
          title: data.title,
        });
      if (data.productId) {
        goodInfo(data.productId);
      }
  }
 async function  goodInfo(id){
			let {data} = await	  getProductDetail(id)
      storeInfo.value = data.storeInfo
			  }
  onLoad((options) => {
    if (options.title) {
      state.title = options.title;
      uni.setNavigationBarTitle({
        title: state.title,
      });
    }
    getRichTextContent(options.id);
  });
</script>

<style lang="scss" scoped>

    .newsDetail{
	
	}
	.newsDetail .title {
		padding: 0 30rpx;
		font-size: 34rpx;
		color: #282828;
		font-weight: bold;
		line-height: 1.5;
	}

	.newsDetail .list {
		margin: 28rpx 30rpx 0 30rpx;
		padding-bottom: 25rpx;
	}

	.newsDetail .list .label {
		font-size: 30rpx;
		color: #B1B2B3;
	}

	.newsDetail .list .item {
		margin-left: 27rpx;
		font-size: 30rpx;
		color: #B1B2B3;
	}

	.newsDetail .list .item .iconfont {
		font-size: 28rpx;
		margin-right: 10rpx;
	}

	.newsDetail .list .item .iconfont.icon-shenhezhong {
		font-size: 26rpx;
	}

	.newsDetail .conters {
		padding: 0 30rpx;
		font-size: 32rpx;
		color: #8A8B8C;
		line-height: 1.7;
	}

	.newsDetail .picTxt {
		width: 690rpx;
		height: 200rpx;
		border-radius: 20rpx;
		border: 1px solid #e1e1e1;
		position: relative;
		margin: 30rpx auto 0 auto;
	}

	.newsDetail .picTxt .pictrue {
		width: 200rpx;
		height: 200rpx;
	}

	.newsDetail .picTxt .pictrue image {
		width: 100%;
		height: 100%;
		border-radius: 20rpx 0 0 20rpx;
		display: block;
	}

	.newsDetail .picTxt .text {
		width: 460rpx;
	}

	.newsDetail .picTxt .text .name {
		font-size: 30rpx;
		color: #282828;
	}

	.newsDetail .picTxt .text .money {
		font-size: 24rpx;
		margin-top: 40rpx;
		font-weight: bold;
	}

	.newsDetail .picTxt .text .money .num {
		font-size: 36rpx;
	}

	.newsDetail .picTxt .text .y_money {
		font-size: 26rpx;
		color: #999;
		text-decoration: line-through;
	}

	.newsDetail .picTxt .label {
		position: absolute;
		background-color: #303131;
		width: 160rpx;
		height: 50rpx;
		right: -7rpx;
		border-radius: 25rpx 0 6rpx 25rpx;
		text-align: center;
		line-height: 50rpx;
		bottom: 24rpx;
	}

	.newsDetail .picTxt .label .span {
		background-image: linear-gradient(to right, #fff71e 0%, #f9b513 100%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
	}

	.newsDetail .picTxt .label:after {
		content: " ";
		position: absolute;
		width: 0;
		height: 0;
		border-bottom: 8rpx solid #303131;
		border-right: 8rpx solid transparent;
		top: -7rpx;
		right: 0;
	}

	.newsDetail .bnt {
		color: #fff;
		font-size: 30rpx;
		width: 690rpx;
		height: 90rpx;
		border-radius: 45rpx;
		margin: 48rpx auto;
		text-align: center;
		line-height: 90rpx;
	}
</style>
